﻿@model SelectList
@{
	ViewBag.Title = "SysUserTypeManageIndex";
    Layout = "~/Views/Shared/_LayoutEmbeddedFrame.cshtml";
}
<style type="text/css">
	#tree
	{
		float: left;
		height: 100%;
		margin: 1px 0 0 0;
		width: 160px;
		background: url("/Content/images/treebg.jpg") no-repeat scroll 0 0 #FFFFFF;
		border: 1px solid #83AAD3;
		vertical-align: top;
		font-family: "font-family:Verdana, Arial, Helvetica, sans-serif";
		font-size: 12px;
	}
	.user-role-title
	{
		width: 100%;
		font-weight: bold;
		color: Black;
		height: 20px;
		border-bottom: 1px solid #83AAD3;
		padding-top: 6px;
	}
	.user-role-title .user-role-img
	{
		background: url("/Content/images/users.gif") no-repeat;
		padding-left: 20px;
		height: 15px;
	}
	.user-role-toolbar
	{
		border-bottom: 1px solid #83AAD3;
		background: #DFECF9;
		height: 28px;
		padding-top: 10px;
	}
	.user-role-toolbar a
	{
		height: 28px;
		float: left;
		padding-left: 5px;
		color: #592C27;
	}
	.user-role-toolbar a:hover
	{
		color: #717070;
	}
	.user-role-toolbar .user-role-toolbar-add span
	{
		background: url("/Content/images/ToolBar/add.png") no-repeat;
		padding-left: 20px;
		height: 20px;
		float: left;
		line-height: 20px;
		vertical-align: middle;
	}
	.user-role-toolbar .user-role-toolbar-edit span
	{
		background: url("/Content/images/toolBar/edit.png") no-repeat;
		padding-left: 20px;
		height: 20px;
		float: left;
		line-height: 20px;
		vertical-align: middle;
	}
	.user-role-toolbar .user-role-toolbar-delete span
	{
		background: url("/Content/images/toolBarDelete.gif") no-repeat;
		padding-left: 20px;
		height: 20px;
		float: left;
		line-height: 20px;
		vertical-align: middle;
	}

</style>
<script type="text/javascript">
    $(function () {
        $("#tree").height($("html").outerHeight());
        $("#userTypeList").height($("html").outerHeight() - 70);

        //如果select存在option  默认选中第一项
        if ($("#userTypeList option").length > 0) {
            var id = $("#userTypeList option:eq(0)").val();
            $("#pageRightFrame").attr("src", "/ModuleSys/SysUserTypeManage/Index/?SysUserTypeID=" + id);
            $("#userTypeList option:eq(0)").focus();
        }

    });

    //角色切换
    function UserTypeChange() {
        if ($("#userTypeList").val() == null)
            return;
        $("#embeddedFrame").attr("src", "/ModuleSys/SysUserTypeManage/Index/?SysUserTypeID=" + $("#userTypeList").val());
    }

    //根据页面状态 创建与编辑用户角色
    function create(pageState) {
        if (pageState == '@Project.Common.EnumPageState.新增')
            window.top.openDialog({ Url: "/ModuleSys/SysUserTypeManage/Create/?pageState=" + pageState, Title: "新增用户类型", Width: 350, Height: 200 });
        else if (pageState == '@Project.Common.EnumPageState.编辑') {
            var id = $("#userTypeList").val();
            if (id == null) {
                //请选择需要编辑的角色！
                window.top.showSysAlert('@(OASys.Resources.Properties.Resources.M10005I)');
                return;
            }
            window.top.openDialog({ Url: "/ModuleSys/SysUserTypeManage/Create/?pageState=" + pageState + "&sysUserTypeID=" + id, Title: "修改用户类型", Width: 350, Height: 200 });
        }
    }

    function deleteUserType() {
        var id = $("#userTypeList").val();
        if (id == null) {
            //请选择需要删除的角色！
            window.top.showSysAlert('@(OASys.Resources.Properties.Resources.M10006I)');
            return;
        }

        top.window.$("#sysConfirm").html("确定要删除？");
        top.window.$("#sysConfirm").dialog({
            resizable: false,
            height: 200,
            title: "系统提示",
            modal: true,
            buttons: {
                "是": function () {
                    $.ajax({
                        type: "POST",
                        url: "/ModuleSys/SysUserTypeManage/Delete",
                        data: "id=" + id,
                        success: function (msg) {
                            msg = eval("(" + msg + ")");
                            if (msg.result == "") {
                                window.location = commonPage.getCurrentUrl();
                                window.top.sysMessage();
                            }
                            else {
                                window.top.sysAlert(msg.result);
                            }
                        }
                    });
                    top.window.$("#sysConfirm").dialog("close");
                },
                "否": function () {
                    top.window.$("#sysConfirm").dialog("close");
                }
            }
        });
    }
</script>
<div id="tree">
	<div class="user-role-title">
		<span class="user-role-img">用户类型</span></div>
	<div class="clear">
	</div>
	<div class="user-role-toolbar">
		<a href="javascript:void(0)" class="user-role-toolbar-add" onclick="create('@Project.Common.EnumPageState.新增')">
			<span>新增</span></a> 
            
            <a href="javascript:void(0)" class="user-role-toolbar-edit" onclick="create('@Project.Common.EnumPageState.编辑')">
				<span>修改</span></a> 
                
                <a href="javascript:void(0)" class="user-role-toolbar-delete"
					onclick="deleteUserType()"><span>删除</span></a>
	</div>
	<div class="clear">
	</div>
	<div class="user-role-content">

		@Html.DropDownList("UserTypeID", Model, new { size = "30", id = "userTypeList", style = "width: 160px;font-size: 12px;", onchange = "UserTypeChange();" })
	</div>
</div>

